import java.util.Scanner;

public class StrategyPatternModule {
    private final Scanner scanner = new Scanner(System.in);
    private final PathPlanner planner = new PathPlanner();
    
    public void execute() {
        while (true) {
            System.out.println("\n===== 智能路径规划 =====");
            System.out.println("1. 最短路径规划");
            System.out.println("2. 避障路径规划");
            System.out.println("3. 多机协同规划");
            System.out.println("4. 返回主菜单");
            System.out.print("请选择路径规划策略(1-4): ");
            
            int choice = scanner.nextInt();
            scanner.nextLine();  // 消耗换行符
            
            switch (choice) {
                case 1 -> {
                    planner.setStrategy(new ShortestPathStrategy());
                    planner.executePathPlanning();
                }
                case 2 -> {
                    planner.setStrategy(new ObstacleAvoidanceStrategy());
                    planner.executePathPlanning();
                }
                case 3 -> {
                    planner.setStrategy(new MultiMachineStrategy());
                    planner.executePathPlanning();
                }
                case 4 -> { return; }
                default -> System.out.println("无效选择，请重新输入");
            }
        }
    }
}